package hongcaosp.app.android.common;

import android.support.v7.widget.RecyclerView;
import android.view.View;

import xlj.lib.android.base.view.OnRecycleItemClickListener;

public abstract class BaseHolder<T> extends RecyclerView.ViewHolder {
    private T data;

    public BaseHolder(View itemView, final OnRecycleItemClickListener recycleItemClickListener) {
        super(itemView);
        if (recycleItemClickListener != null) {
            itemView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    recycleItemClickListener.onItemClick(getAdapterPosition());
                }
            });

            itemView.setOnLongClickListener(new View.OnLongClickListener() {
                @Override
                public boolean onLongClick(View v) {
                    recycleItemClickListener.onItemLongClick(getAdapterPosition());
                    return false;
                }
            });
        }

    }

    public BaseHolder(View itemView) {
        super(itemView);
    }

    public  void setData(T t) {
        this.data = t;
    }

    public T getData() {
        return data;
    }
}
